﻿using System;
using System.Collections;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Data;

namespace SQLS
{
    [XmlRoot("SQLS")]
    public class sqls
    {
        [XmlAttribute("ovsc")]
        public string OVSC;

        [XmlAttribute("description")]
        public string Description;

        [XmlAttribute("sqlserver")]
        public string SQLServer;

        [XmlAttribute("database")]
        public string Database;

        [XmlAttribute("inputpath")]
        public string InputPath;

        [XmlAttribute("outputpart")]
        public string OutputPath;

        [XmlAttribute("clearoutput")]
        public bool ClearOutput;

        [XmlAttribute("orderby")]
        public bool OrderByPrefix;

        [XmlAttribute("useinput")]
        public bool UseInput;

        private ArrayList _SQLFiles;

        public sqls()
        {
            _SQLFiles = new ArrayList();
        }

        [XmlElement("sqlfiles")]
        public SQLFile[] SQLFiles
        {
            get
            {
                SQLFile[] sqlfiles = new SQLFile[_SQLFiles.Count];
                _SQLFiles.CopyTo(sqlfiles);
                return sqlfiles;
            }
            set
            {
                if (value == null) return;

                SQLFile[] sqlfiles = (SQLFile[]) value;
                _SQLFiles.Clear();
                foreach (SQLFile sqlfile in sqlfiles)
                    _SQLFiles.Add(sqlfile);
            }
        }

        public int AddItem(SQLFile SQLFile)
        {
            return _SQLFiles.Add(SQLFile);
        }
    }

    public class SQLFile
    {
        [XmlAttribute("filename")]
        public string filename;

        [XmlAttribute("ischecked")]
        public bool ischecked;

        public SQLFile()
        { }

        public SQLFile(string FileName, bool Checked)
        {
            filename = FileName;

            ischecked = Checked;
        }
    }
}
